﻿using EmailClient.Model;
using LumiSoft.Net.MIME;
using ServiceStack.OrmLite;
using System;
using System.Windows;

namespace EmailClient
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {

        
        public static string DBPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "EmailClient.db");
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //For localization
            ResourcesLoader.LoadResources(this.Resources);

            OrmLiteConfig.DialectProvider = SqliteDialect.Provider;
            var dbFactory = new OrmLiteConnectionFactory(DBPath);
            using (var db = dbFactory.Open())
            {
                db.CreateTable<EmailAccount>();
                db.CreateTable<Letter>();
                db.CreateTable<Attachment>();
                db.CreateTable<MailFolder>();
                db.CreateTable<Log>();
            }
                   
            // Create the startup window
            var wnd = new MainWindow();                    
            wnd.Show();
        }    
               
    }
}
